// doorlever.txt -  A lever that opens nearby gates. When it is walked onto, asks if the
// party wants to pull it. if they do, swaps up to 2 terrain spots. 

// (When a terrain type is defined, you can set a swap terrain type for
// is, a terrain type that it changes to if it is opened/closed. For
// example, a closed gate's swap terrain is an open gate.

// Memory Cells - 
//   0,1 - The x,y coordinated of a gate this level opens. If both are left at 0, doesn't
//     do anything.
//   2,3 - Same
//   4,5 - Same
//   6,7 - Same

beginterrainscript; 

variables;

	short choice;
body;

beginstate INIT_STATE;

	break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;

break;

beginstate STEP_INTO_SPOT_STATE;
	reset_dialog_preset_options(2);
	choice = run_dialog(0);
	if (choice == 1)
		end();
	
	flip_terrain(my_loc_x(),my_loc_y());
	play_sound(106);
	play_sound(99);
	print_str_color("You hear the sounds of chains and grinding gears.",2);

	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) 
		flip_terrain(get_memory_cell(0),get_memory_cell(1));

	if ((get_memory_cell(2) > 0) || (get_memory_cell(3) > 0)) 
		flip_terrain(get_memory_cell(2),get_memory_cell(3));

	if ((get_memory_cell(4) > 0) || (get_memory_cell(5) > 0)) 
		flip_terrain(get_memory_cell(4),get_memory_cell(5));

	if ((get_memory_cell(6) > 0) || (get_memory_cell(7) > 0)) 
		flip_terrain(get_memory_cell(6),get_memory_cell(7));
break;
